package app.foo.planetadnzombiedemo;

import androidx.appcompat.app.AppCompatActivity;

import android.graphics.BitmapFactory;
import android.os.Bundle;

import app.foo.planetadnzombiedemo.global.Config;
import app.foo.planetadnzombiedemo.global.DeviceHelper;
import app.foo.planetadnzombiedemo.view.Gameview;


public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        init();
        setContentView(new Gameview(this));
    }
    private void init() {
        //获取设备chicun
        Config.deveWidth= DeviceHelper.getDeviceInfo(this)[0];
        Config.deveHeight= DeviceHelper.getDeviceInfo(this)[1];

        //获得背景图片
        Config.gameBK= BitmapFactory.decodeResource(getResources(),R.drawable.bk);

        //获得缩放比：利用背景图片作为基准
        Config.scaleWidth=Config.deveWidth/(float)Config.gameBK.getWidth();
        Config.scaleHeight=Config.deveHeight/(float)Config.gameBK.getHeight();
        //使用缩放生成目标图片
        Config.gameBK=DeviceHelper.resizeBitmap(Config.gameBK);
        Config.seedBank=DeviceHelper.resizeBitmap(BitmapFactory.decodeResource(getResources(),
                R.drawable.seedbank));
        Config.seedBankLocationX=(Config.deveWidth-Config.seedBank.getWidth())/2;

    }
}
